;(function($){
	$.Tab=$.Widget.extend({
		init: function(tabObject){
			this.el=$($(tabObject.tab).get(0));
			this.current=null;
			{
				var c=this.el.find("li.current:first");
				if(c.size()>0){
					this.current=$(c);
				}else{
					this.current = this.el.find("li:first");
				}
			}
			this.bind();
			this.current.click();
		}
		,getEl: function(){
			return this.el;
		}
		,bind: function(){
			this.getEl().bind('click',this,function(event){
				var el=$(event.srcElement||event.target);
				var tabs=event.data;
				var tab = el.is('li')?el:el.parent().is('li')?el.parent():null;
				if(tab){
					tabs.select(tab);
				}
			});
		}
		,select:function($tab){
			this.current.removeClass('current');
			$tab.addClass('current');
			this.current=$tab;
		}
	});
})(jQuery);